<?php
// +----------------------------------------------------------------------
// | Description: 1
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------
// | Date: 2018-02-01 17:15:14
// +----------------------------------------------------------------------

namespace app\client\model;

use app\common\model\CommonClient;

class Comment extends CommonClient
{
    protected $fuzzyConditions = ['UserName', 'OrderId'];
    protected $clearConditions = ['IsHidden', 'ProductId', 'ReviewMark'];
    protected $returnFields = '';
    protected $rangeConditions = null;
    protected $union_fuzzyConditions = null;
    protected $foreignConditions = null;
    protected $name = 'shop_goods_comments';

    /**
     * 解析搜索条件
     */
    public function getClientDataList()
    {
        $this->page = $this->param['page'] or 1;
        $this->limit = $this->param['limit'] or $this->limit;
        $this->orderByString = $this->param['orderByString'];
        $this->param['IsHidden'] = 0;   // 开启软删除 

        $this->specialCondition();
        $this->M_fuzzy();
        $this->M_clear();
        $this->M_range();
        $this->M_union_field();
        $this->M_UnionSelect();
        $this->M_order();
        // $this->where($this -> name.'.IsDelete', 0);

        if ($this->limit == -1) {
            $resData = $this->field($this->returnFields)->select();
        } else {
            $resData = $this->field($this->returnFields)->page($this->page, $this->limit)->select();
        }
// p($this -> getlastsql());
        $this->specialCondition();
        $this->M_fuzzy();
        $this->M_clear();
        $this->M_range();
        $this->M_union_field();
        $this->M_UnionSelect();
        $this->M_order();
        // $this->where('IsDelete', 0);

        $dataCount = $this->count();
        $data['list'] = $resData;
        $data['dataCount'] = $dataCount;
        return $this->filter($data);
    }

    /**
     * 过滤
     *
     * @return void
     */
    public function filter($data)
    {
        foreach($data['list'] as $k => $v){
            $data['list'][$k]['OrderId'] = (string)$v['OrderId'];
        }
        return $data;
    }
}
